package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2024-12-25
 * Time:23:20
 */
public class Demo8 {
    //private static boolean isQuit=false;
    public static void main(String[] args) throws InterruptedException {
        boolean isQuit=false;
        Thread t=new Thread(()->{
            while (!isQuit){
                //此处的打印可以替换成任意的逻辑来表示线程的实际工作内容
                System.out.println("线程工作中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程工作完毕");
        });
        t.start();
        Thread.sleep(5000);
        //isQuit=true;
        System.out.println("设置isQuit为true");
    }
}
